package org.example.virtualsensors.service;

import org.example.virtualsensors.entity.model.Sensor;
import org.springframework.stereotype.Service;

import java.util.concurrent.ConcurrentHashMap;

@Service
public class SensorDataService {
    private final ConcurrentHashMap<String, Sensor> sensorDataCache = new ConcurrentHashMap<>();

    public void updateSensorData(Sensor sensorData) {
        sensorDataCache.put(sensorData.getEmsItem().getItemKey(), sensorData);
    }

    public Sensor getSensorData(String item_key) {
        return sensorDataCache.get(item_key);
    }

}